package com.jzt.ic.service;

import com.jzt.service.ServiceA;
import com.jzt.service.ServiceB;
import com.jzt.service.ServiceC;
import com.yvan.dsf.anno.DsfConsumer;
import com.yvan.dsf.anno.DsfService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by luoyifan on 2017/11/24.
 */
@DsfService
public class ServiceCImp implements ServiceC {

    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceCImp.class);
    private static final AtomicLong ABC_COUNTS = new AtomicLong(0);
    private static final AtomicLong C_COUNTS = new AtomicLong(0);

    @DsfConsumer
    private ServiceA serviceA;
    @DsfConsumer
    private ServiceB serviceB;

    @Override
    public String linkABC() {
        LOGGER.info("abc success:" + ABC_COUNTS.incrementAndGet());
        return "C";
    }

    @Override
    public String invokeA(String v) {
        return serviceA.aFinish(v + "c");
    }

    @Override
    public String invokeB(String v) {
        return serviceB.bFinish(v + "c");
    }

    @Override
    public String cFinish(String v) {
        LOGGER.info("c finish:" + C_COUNTS.incrementAndGet());
        return v + "c";
    }
}
